package com.da.javatest.leetCode;

/**
 * @author chenlida
 * @date 2019/1/19 14:02
 * @description
 */
public class Code888 {
    public int[] fairCandySwap(int[] A, int[] B) {
        int totalA = 0, totalB = 0;
        for (int i : A) {
            totalA += i;
        }
        for (int i : B) {
            totalB += i;
        }
        int diff = (totalA - totalB) / 2;
        for (int i : A) {
            for (int j : B) {
                if (i == j + diff) {
                    return new int[] {i, j};
                }
            }
        }
        return null;
    }
}
